/*
 * @(#)VideoMod.java 2012-01-12
 *
 * Copyright 2011 北龙中网（北京）科技有限责任公司. All rights reserved.
 */
package cn.shangjia.shop.controller.mod;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import cn.shangjia.common.dao.support.Page;
import cn.shangjia.common.domain.audit.ShopVideo;
import cn.shangjia.common.util.StringUtils;
import cn.shangjia.shop.controller.base.AbstractController;
import cn.shangjia.shop.service.ShopVideoService;

/**
 * @description 商铺视频控制器
 * @author <a href="mailto:wangxin@knet.cn">北京王欣</a>
 * @version 
 * @date 2011-11-03 上午10:34:16
 */
@Controller
public class VideoMod extends AbstractController{
	@Resource
	private ShopVideoService shopVideoService;
	
	/**
	 *  商铺视频列表页面
	 * 
	 * @param userid
	 * @param pageNo
	 * @param model
	 * @return
	 * @author <a href="mailto:jinzhongze@knet.cn">jinzhongze</a>
	 */
	@RequestMapping("/shop/module/video/index.html")
	public String mod_video(ModelMap model, String pageNo,String userid) {
		Page<ShopVideo> page = shopVideoService.findShopVideoPage(userid, getInt(pageNo), config.getVideoCurrentPagesize());
		model.addAttribute("page", page);
		return "shop/module/video/index";
	}
	
	/**
	 *  商铺视频详细页面
	 * 
	 * @param model
	 * @param userid
	 * @param id
	 * @return
	 * @author <a href="mailto:jinzhongze@knet.cn">jinzhongze</a>
	 */
	@RequestMapping("/shop/module/video/detail.html")
	public String mod_video_detail(ModelMap model, String userid, String id) {
		
		if (StringUtils.isEmpty(id))
			return mod_video(model, "1", userid);
		
		ShopVideo shopVideo = shopVideoService.getShopVideo(id);
		
		if (shopVideo == null) 
			return mod_video(model, "1", userid);
		
		model.addAttribute("shopVideo", shopVideo);
		
		return "shop/module/video/detail";
	}

}
